home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
wndw40.zip
/
WNDW40-.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-12-11
|
25KB
|
545 lines
{ =========================================================================== }
{ Wndw40-.pas - unit for random-access, multi-level windows ver 4.0, 12-12-87 }
{ }
{ This file has a partial code listing for serial and random access, }
{ multi-level windows. It works on any IBM or compatible including PCjr, }
{ IBM 3270 PC, and the PS/2 systems, in any video mode. It uses QWIK40.TPU }
{ for fast screen writing on any video page. }
{ (c) James H. LeMay 1987 }
{ =========================================================================== }
{$R-,S-,I-,D-,T-,F-,V-,B-,N-,L+ }
UNIT Wndw;
INTERFACE
USES Crt,Qwik,WndwVars;
{ -- Basic Window Utilities -- }
function Attr (Foreground,Background: byte): byte;
procedure Qbox (Row,Col,Rows,Cols: byte; Wattr,Battr: integer;
BrdrSel: Borders);
procedure RestoreTurboWindow;
procedure InitWindow (Wattr: integer; ClearScr: boolean);
function HeapOK (NumOfBytes: word): boolean;
procedure SetWindowModes (SumOfAllModes: byte);
procedure MakeWindow (Row,Col,Rows,Cols: byte; Wattr,Battr: integer;
BrdrSel: Borders; WindowName: WindowNames);
procedure PartitionWindow (Partition: DirType; WindowRowOrCol: byte);
procedure PartitionCross (WindowRow, WindowCol: byte);
procedure RemoveWindow;
procedure TitleWindow (TopOrBottom,Justify: DirType; Title: string);
procedure ClearTitle (TopOrBottom: DirType);
procedure ClearWindow;
procedure ScrollWindow (RowBegin,RowEnd: byte; Dir: DirType);
{ -- Window management utilities -- }
procedure HideWindow;
procedure ShowWindow (WindowName: WindowNames);
procedure MoveWindow (Dir: DirType; NumOfChars: byte);
function GetLevelIndex (WindowName: WindowNames): byte;
procedure AccessWindow (WindowName: WindowNames);
IMPLEMENTATION
const
NoShadow = $00;
BothShadows = $0C; { ShadowLeft+ShadowRight }
FixedOrPermModes = $03; { FixedMode+PermMode }
{ =========================================================================== }
{ NAME: Attr ver 4.0, 12-12-87 }
{ DESCRIPTION: Converts Turbo color constants into an attribute and masks }
{ any accidental blink bit. However, the use of the new }
{ background colors constants in WNDWVARS.PAS is recommended }
{ in lieu of this function. }
{ PARAMETERS: ForeGround - Color of text foreground }
{ BackGround - Color of text background }
{ =========================================================================== }
function Attr; { (Foreground,Background: byte): byte; }
begin
Attr := ((BackGround shl 4) + ForeGround) and $7F;
end;
{ =========================================================================== }
{ NAME: RestoreTurboWindow ver 4.0, 12-12-87 }
{ DESCRIPTION: Restores the Turbo window, attribute, cursor location, }
{ and window identification for the top Level Index. }
{ =========================================================================== }
procedure RestoreTurboWindow;
begin
with TopWndwStat do
begin
TextAttr:=WSWattr; { Turbo's Attribute }
if VideoPage=0 then
if WSbrdr=NoBrdr then
window (WScol,WSrow,WScol2,WSrow2)
else window (succ(WScol),succ(WSrow),pred(WScol2),pred(WSrow2));
GotoRC (WSwhereR,WSwhereC);
end
end;
{ =========================================================================== }
{ NAME: InitWindow ver 4.0, 12-12-87 }
{ DESCRIPTION: Initializes the window variables. Run this routine first! }
{ PARAMETERS: }
{ Wattr - Starting window attribute (0-255) }
{ ClearScr - Set to true if you want the screen initially cleared }
{ =========================================================================== }
procedure InitWindow; { (Wattr: integer; ClearScr: boolean); }
begin
CheckSnow:=Qsnow;
LI:=0; { Current Level Index }
HLI:=MaxWndw+1; { Hidden window Level Index }
with TopWndwStat,Margins do { Set top level stats }
begin
WSrow := 1; WSWattr := Wattr;
WScol := 1; WSBattr := Wattr;
WSrows := CRTrows; WSbrdr := NoBrdr;
WScols := CRTcols; WSname := Window0;
WSrow2 := CRTrows; WSwhereR := 1;
WScol2 := CRTcols; WSwhereC := 1;
WSmodes := PermMode;
ULbytes := 0;
WndwStat[0] := TopWndwStat; { Save a copy }
LeftMargin := WScol;
RightMargin := WScol2;
TopMargin := WSrow;
BottomMargin := WSrow2;
WindowModes := 0;
case SystemID of
$FC,$F8: ZoomDelay:=18; { 80286 or 80386 machines }
else ZoomDelay:=12;
end;
RestoreTurboWindow;
if ClearScr then
Qfill (1,1,CRTrows,CRTcols,Wattr,' ');
end;
end;
{ =========================================================================== }
{ NAME: SetWindowModes ver 4.0, 12-12-87 }
{ DESCRIPTION: Checks and set the variable WindowModes. }
{ PARAMETERS: SumOfAllModes - A sum of all the modes added together. }
{ =========================================================================== }
procedure SetWindowModes; { (SumOfAllModes: byte); }
begin
{ -- Turn off HideMode -- }
WindowModes:=SumOfAllModes and ($FF-HideMode);
{ -- if both shadows, clear ShadowLeft -- }
if (WindowModes and BothShadows)=BothShadows then
WindowModes:=WindowModes-ShadowLeft;
end;
{ =========================================================================== }
{ NAME: HeapOK ver 4.0, 12-12-87 }
{ DESCRIPTION: Checks for enough memory on the heap used by MakeWindow. }
{ PARAMETERS: NumOfBytes - number of bytes needed on the heap }
{ =========================================================================== }
function HeapOK; { (NumOfBytes: word): boolean; }
begin
if maxavail<NumOfBytes then
begin
ProgrammingError (1);
HeapOK := false
end
else HeapOK := true
end;
{ =========================================================================== }
{ NAME: Qbox ver 4.0, 12-12-87 }
{ DESCRIPTION: Writes a window with optional border. }
{ PARAMETERS: See MakeWindow. }
{ =========================================================================== }
procedure Qbox; { (Row,Col,Rows,Cols: byte;
Wattr,Battr: integer; BrdrSel: Borders); }
var Row2,Col2: byte;
begin
if (Rows>=2) and (Cols>=2) then
begin
Row2:=pred(Row+Rows);
Col2:=pred(Col+Cols);
if BrdrSel<>NoBrdr then
with Brdr[BrdrSel] do
begin
Qwrite ( Row , Col ,Battr,TL);
Qfill ( Row ,succ(Col),1 ,Cols-2,Battr,TH);
Qwrite ( Row , Col2 ,Battr,TR);
Qfill (succ(Row), Col ,Rows-2,1 ,Battr,LV);
Qfill (succ(Row), Col2,Rows-2,1 ,Battr,RV);
Qwrite ( Row2, Col ,Battr,BL);
Qfill ( Row2,succ(Col),1 ,Cols-2,Battr,BH);
Qwrite ( Row2, Col2 ,Battr,BR);
Qfill (succ(Row),succ(Col),Rows-2,Cols-2,Wattr,' ')
end
else Qfill (Row,Col,Rows,Cols,Wattr,' ');
end;
end;
{ =====================